package cn.micai.base.asyn;

import org.jetbrains.annotations.Nullable;

/**
 * 描述：回调模式-测试类
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/5/25 17:18
 */
public class CallBackTest {

    public static void main(String [] args) {
        /*Server server = new Server();
        Client client = new Client(server);
        client.sendMsg("Server, Hello...");*/
        /*List emptyList = Collections.EMPTY_LIST;
        System.out.println(emptyList);*/

        // 先全局CallbackManager中添加回调
        CallbackManager.getInstance().addCallback(CallbackType.WX_PAY, new IGlobalCallback() {
            @Override
            public void executeCallback(@Nullable Object args) {
                System.out.println("回调执行任务......");
            }
        });

        // 延迟发送消息模拟异步耗时操作
        new Thread(new Runnable() {
            @Override
            public void run() {
                IGlobalCallback callback = CallbackManager.getInstance().getCallback(CallbackType.WX_PAY);
                if (callback != null) {
                    callback.executeCallback("微信支付测试回调......");
                }
            }
        });
    }

}
